﻿using System;
using System.Collections.Generic;
using System.Configuration;

namespace xxpl1.Utils
{
    public class Settings
    {
        private static readonly Settings instance = new Settings();
        private readonly List<string> rangeMine = new List<string>();
        private readonly List<string> gaeapp = new List<string>();
        private readonly List<string> gaehttps = new List<string>();
        private readonly List<string> gaehttp = new List<string>();
        private readonly List<string> gaeipv6 = new List<string>();
        private readonly string use;
        private readonly int port;
        private bool enableRange;
        private bool enableCache;
        private bool zipHeader;
        private bool async;

        public static Settings Instance
        {
            get { return instance; }
        }

        public Settings()
        {
            rangeMine.AddRange(ConfigurationManager.AppSettings["RangeMime"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
            gaeapp.AddRange(ConfigurationManager.AppSettings["GAEAPP"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
            gaehttps.AddRange(ConfigurationManager.AppSettings["GAEHTTPS"].Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries));
            gaehttp.AddRange(ConfigurationManager.AppSettings["GAEHTTP"].Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries));
            gaeipv6.AddRange(ConfigurationManager.AppSettings["GAEIPV6"].Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries));
            use = ConfigurationManager.AppSettings["Use"];
            port = int.Parse(ConfigurationManager.AppSettings["Port"]);
            enableRange = bool.Parse(ConfigurationManager.AppSettings["EnableRange"]);
            enableCache = bool.Parse(ConfigurationManager.AppSettings["EnableCache"]);
            zipHeader = bool.Parse(ConfigurationManager.AppSettings["ZipHeader"]);
            async = bool.Parse(ConfigurationManager.AppSettings["Async"]);
        }

        public List<string> RangeMine
        {
            get { return rangeMine; }
        }

        public bool Async
        {
            get { return async; }
        }

        public bool ZipHeader
        {
            get { return zipHeader; }
        }

        public List<string> Gaeapp
        {
            get { return gaeapp; }
        }

        public List<string> Gaehttps
        {
            get { return gaehttps; }
        }

        public List<string> Gaehttp
        {
            get { return gaehttp; }
        }

        public List<string> Gaeipv6
        {
            get { return gaeipv6; }
        }

        public string Use
        {
            get { return use; }
        }

        public int Port
        {
            get { return port; }
        }

        public bool EnableRange
        {
            get { return enableRange; }
            set { enableRange = value; }
        }

        public bool EnableCache
        {
            get { return enableCache; }
            set { enableCache = value; }
        }
    }
}
